unit prSHYBTSECheckDetay;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, uClassReport, cxGraphics, cxControls,
  cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
  cxPCdxBarPopupMenu, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage,
  Data.DB, cxDBData, Vcl.Menus, Data.Win.ADODB, Vcl.ImgList, Vcl.ActnList,
  cxPropertiesStore, Vcl.StdCtrls, cxButtons, cxGridLevel, cxClasses,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, cxPC, cxGroupBox, cxSpinEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit,
  cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, cxHeader;

type
  TfmSHYBTSECheckDetay = class(TfmClassReport)
    Label6: TLabel;
    Label1: TLabel;
    lcTSEActList: TcxLookupComboBox;
    lcSHYBActList: TcxLookupComboBox;
    Label5: TLabel;
    Label7: TLabel;
    edUnvan: TcxTextEdit;
    seLimit: TcxSpinEdit;
    Label2: TLabel;
    lcTseNo: TcxLookupComboBox;
    aqSHYBActionList: TADOQuery;
    aqTSEActionList: TADOQuery;
    dsTSEActionList: TDataSource;
    dsSHYBActionList: TDataSource;
    aqTseNo: TADOQuery;
    dsTseNo: TDataSource;
    grdReportssID: TcxGridDBColumn;
    grdReportsUnvan: TcxGridDBColumn;
    grdReportYTSsFirmaAd: TcxGridDBColumn;
    grdReportYTSsAdres: TcxGridDBColumn;
    grdReportYTSsSehirAd: TcxGridDBColumn;
    grdReportYTSsTelefon: TcxGridDBColumn;
    grdReportYTSYetkiliAdSoyad: TcxGridDBColumn;
    grdReportTseNo: TcxGridDBColumn;
    TS2: TcxTabSheet;
    aqGuncellenmeyen: TADOQuery;
    dsGuncellenmeyen: TDataSource;
    cxReportG: TcxGrid;
    grdReportG: TcxGridDBTableView;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridDBColumn2: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    cxGridDBColumn7: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure acListExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmSHYBTSECheckDetay: TfmSHYBTSECheckDetay;

implementation

uses Data;

{$R *.dfm}

procedure TfmSHYBTSECheckDetay.acListExecute(Sender: TObject);
var
  ExCursor: TCursor;
begin
  inherited;
  if lcSHYBActList.Text = '' then
  begin
    ShowMessage('SHYB Action Grubunu Giriniz!');
    lcSHYBActList.SetFocus;
    Exit;
  end;

  if lcTSEActList.Text = '' then
  begin
    ShowMessage('TSE Action Grubunu Giriniz!');
    lcTSEActList.SetFocus;
    Exit;
  end;

  ExCursor := Screen.Cursor;
  Screen.Cursor := crSQLWait;
  try
    with aqList do
    begin
      Close;
      SQL.Text := 'EXEC SP_FIRMAYAKALADETAY @ActionGrupTSE=:ActionGrupTSE,@ActionGrupSHYB=:ActionGrupSHYB,@UnvanLimit=:UnvanLimit,@TseNo=:TseNo,@Unvan=:Unvan';
      Parameters.ParamByName('ActionGrupTSE').Value := lcTSEActList.EditValue;
      Parameters.ParamByName('ActionGrupSHYB').Value := lcSHYBActList.EditValue;
      Parameters.ParamByName('UnvanLimit').Value := seLimit.Value;
      Parameters.ParamByName('TseNo').Value := lcTseNo.EditValue;
      Parameters.ParamByName('Unvan').Value := edUnvan.Text;
      Open;
    end;

    with aqGuncellenmeyen do
    begin
      Close;
      SQL.Text := 'EXEC SP_FIRMAYAKALADETAY_GUNCELLENMEYEN @ActionGrupTSE=:ActionGrupTSE,@ActionGrupSHYB=:ActionGrupSHYB,@UnvanLimit=:UnvanLimit,@TseNo=:TseNo,@Unvan=:Unvan';
      Parameters.ParamByName('ActionGrupTSE').Value := lcTSEActList.EditValue;
      Parameters.ParamByName('ActionGrupSHYB').Value := lcSHYBActList.EditValue;
      Parameters.ParamByName('UnvanLimit').Value := seLimit.Value;
      Parameters.ParamByName('TseNo').Value := lcTseNo.EditValue;
      Parameters.ParamByName('Unvan').Value := edUnvan.Text;
      Open;
    end;
  finally
    Screen.Cursor := ExCursor;
  end;
end;

procedure TfmSHYBTSECheckDetay.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
  fmSHYBTSECheckDetay := nil;
end;

procedure TfmSHYBTSECheckDetay.FormCreate(Sender: TObject);
begin
  inherited;
  aqSHYBActionList.Close;
  aqSHYBActionList.Open;

  aqTSEActionList.Close;
  aqTSEActionList.Open;

  aqTseNo.Close;
  aqTseNo.Open;
end;

end.
